<template>
	<view>
		<web-view :src="webUrl"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				webUrl: ''
			};
		},

		onLoad() {
			const webUrl = uni.getStorageSync('webUrl') || this.COFIG?.staticUrl; //默认先取缓存中存储的上次可以访问的域名
			const lastStr = webUrl.slice(-1);//判断域名是否带斜杠/
			const privacyPage = lastStr == "/" ? "suggestion.html" : "/suggestion.html"
			this.webUrl = webUrl + privacyPage
		},
		
		onReady(){
			this.renderView()
		},
		
		methods:{
			renderView(){
				let height = 0; //定义动态的高度变量
				let statusbar = 0; // 动态状态栏高度
				let safeAreaBottom = 0
				uni.getSystemInfo({ // 获取当前设备的具体信息
					success: (sysinfo) => {
						statusbar = sysinfo.statusBarHeight;
						height = sysinfo.windowHeight;
						safeAreaBottom = sysinfo.safeAreaInsets?.bottom;
					}
				});
				let currentWebview = this.$scope.$getAppWebview(); //获取当前web-view
				setTimeout(function() {
					var wv = currentWebview.children()[0];
					wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度，单位为px
						top: statusbar + 44, //此处是距离顶部的高度，应该是你页面的头部
						height: height - statusbar - 44 - safeAreaBottom //webview的高度,减去状态栏
					})
				}, 500); //如页面初始化调用需要写延迟
			}
		}
	};
</script>

<style scoped lang="scss">

</style>